.class public Lcom/bitauto/autoeasy/widget/RemoteImageView;
.super Landroid/widget/ImageView;
.source "RemoteImageView.java"


# annotations
.annotation system Ldalvik/annotation/MemberClasses;
    value = {
        Lcom/bitauto/autoeasy/widget/RemoteImageView$DownloadTask;
    }
.end annotation


# static fields
.field private static MAX_FAILURES:I

.field private static TAG:Ljava/lang/String;


# instance fields
.field private mCurrentlyGrabbedUrl:Ljava/lang/String;

.field private mDefaultImage:Ljava/lang/Integer;

.field private mFailure:I

.field private mGridView:Landroid/widget/GridView;

.field private mListView:Landroid/widget/ListView;

.field private mPosition:I

.field private mUrl:Ljava/lang/String;


# direct methods
.method static constructor <clinit>()V
    .locals 1

    .prologue
    .line 45
    const/4 v0, 0x3

    sput v0, Lcom/bitauto/autoeasy/widget/RemoteImageView;->MAX_FAILURES:I

    .line 47
    const-string v0, "RemoteImageView"

    sput-object v0, Lcom/bitauto/autoeasy/widget/RemoteImageView;->TAG:Ljava/lang/String;

    .line 40
    return-void
.end method

.method public constructor <init>(Landroid/content/Context;)V
    .locals 0
    .parameter "context"

    .prologue
    .line 60
    invoke-direct {p0, p1}, Landroid/widget/ImageView;-><init>(Landroid/content/Context;)V

    .line 61
    invoke-direct {p0}, Lcom/bitauto/autoeasy/widget/RemoteImageView;->init()V

    .line 62
    return-void
.end method

.method public constructor <init>(Landroid/content/Context;Landroid/util/AttributeSet;)V
    .locals 0
    .parameter "context"
    .parameter "attrs"

    .prologue
    .line 55
    invoke-direct {p0, p1, p2}, Landroid/widget/ImageView;-><init>(Landroid/content/Context;Landroid/util/AttributeSet;)V

    .line 56
    invoke-direct {p0}, Lcom/bitauto/autoeasy/widget/RemoteImageView;->init()V

    .line 57
    return-void
.end method

.method public constructor <init>(Landroid/content/Context;Landroid/util/AttributeSet;I)V
    .locals 0
    .parameter "context"
    .parameter "attrs"
    .parameter "defStyle"

    .prologue
    .line 50
    invoke-direct {p0, p1, p2, p3}, Landroid/widget/ImageView;-><init>(Landroid/content/Context;Landroid/util/AttributeSet;I)V

    .line 51
    invoke-direct {p0}, Lcom/bitauto/autoeasy/widget/RemoteImageView;->init()V

    .line 52
    return-void
.end method

.method static synthetic access$0(Lcom/bitauto/autoeasy/widget/RemoteImageView;)V
    .locals 0
    .parameter

    .prologue
    .line 217
    invoke-direct {p0}, Lcom/bitauto/autoeasy/widget/RemoteImageView;->loadDefaultImage()V

    return-void
.end method

.method static synthetic access$1()Ljava/lang/String;
    .locals 1

    .prologue
    .line 47
    sget-object v0, Lcom/bitauto/autoeasy/widget/RemoteImageView;->TAG:Ljava/lang/String;

    return-object v0
.end method

.method static synthetic access$2(Lcom/bitauto/autoeasy/widget/RemoteImageView;)Ljava/lang/String;
    .locals 1
    .parameter

    .prologue
    .line 73
    iget-object v0, p0, Lcom/bitauto/autoeasy/widget/RemoteImageView;->mUrl:Ljava/lang/String;

    return-object v0
.end method

.method static synthetic access$3(Lcom/bitauto/autoeasy/widget/RemoteImageView;)Landroid/widget/ListView;
    .locals 1
    .parameter

    .prologue
    .line 93
    iget-object v0, p0, Lcom/bitauto/autoeasy/widget/RemoteImageView;->mListView:Landroid/widget/ListView;

    return-object v0
.end method

.method static synthetic access$4(Lcom/bitauto/autoeasy/widget/RemoteImageView;)I
    .locals 1
    .parameter

    .prologue
    .line 88
    iget v0, p0, Lcom/bitauto/autoeasy/widget/RemoteImageView;->mPosition:I

    return v0
.end method

.method static synthetic access$5(Lcom/bitauto/autoeasy/widget/RemoteImageView;Ljava/lang/String;)V
    .locals 0
    .parameter
    .parameter

    .prologue
    .line 78
    iput-object p1, p0, Lcom/bitauto/autoeasy/widget/RemoteImageView;->mCurrentlyGrabbedUrl:Ljava/lang/String;

    return-void
.end method

.method private init()V
    .locals 0

    .prologue
    .line 68
    return-void
.end method

.method private loadDefaultImage()V
    .locals 1

    .prologue
    .line 218
    iget-object v0, p0, Lcom/bitauto/autoeasy/widget/RemoteImageView;->mDefaultImage:Ljava/lang/Integer;

    if-eqz v0, :cond_0

    .line 219
    iget-object v0, p0, Lcom/bitauto/autoeasy/widget/RemoteImageView;->mDefaultImage:Ljava/lang/Integer;

    invoke-virtual {v0}, Ljava/lang/Integer;->intValue()I

    move-result v0

    invoke-virtual {p0, v0}, Lcom/bitauto/autoeasy/widget/RemoteImageView;->setImageResource(I)V

    .line 220
    :cond_0
    return-void
.end method


# virtual methods
.method public setDefaultImage(Ljava/lang/Integer;)V
    .locals 0
    .parameter "resid"

    .prologue
    .line 211
    iput-object p1, p0, Lcom/bitauto/autoeasy/widget/RemoteImageView;->mDefaultImage:Ljava/lang/Integer;

    .line 212
    return-void
.end method

.method public setImageUrl(Ljava/lang/String;)V
    .locals 4
    .parameter "url"

    .prologue
    const/4 v2, 0x0

    .line 109
    iget-object v1, p0, Lcom/bitauto/autoeasy/widget/RemoteImageView;->mListView:Landroid/widget/ListView;

    if-nez v1, :cond_0

    iget-object v1, p0, Lcom/bitauto/autoeasy/widget/RemoteImageView;->mCurrentlyGrabbedUrl:Ljava/lang/String;

    if-eqz v1, :cond_0

    iget-object v1, p0, Lcom/bitauto/autoeasy/widget/RemoteImageView;->mCurrentlyGrabbedUrl:Ljava/lang/String;

    invoke-virtual {v1, p1}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v1

    if-eqz v1, :cond_0

    .line 137
    :goto_0
    return-void

    .line 114
    :cond_0
    iget-object v1, p0, Lcom/bitauto/autoeasy/widget/RemoteImageView;->mUrl:Ljava/lang/String;

    if-eqz v1, :cond_1

    iget-object v1, p0, Lcom/bitauto/autoeasy/widget/RemoteImageView;->mUrl:Ljava/lang/String;

    invoke-virtual {v1, p1}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v1

    if-eqz v1, :cond_1

    .line 115
    iget v1, p0, Lcom/bitauto/autoeasy/widget/RemoteImageView;->mFailure:I

    add-int/lit8 v1, v1, 0x1

    iput v1, p0, Lcom/bitauto/autoeasy/widget/RemoteImageView;->mFailure:I

    .line 116
    iget v1, p0, Lcom/bitauto/autoeasy/widget/RemoteImageView;->mFailure:I

    sget v2, Lcom/bitauto/autoeasy/widget/RemoteImageView;->MAX_FAILURES:I

    if-le v1, v2, :cond_2

    .line 117
    sget-object v1, Lcom/bitauto/autoeasy/widget/RemoteImageView;->TAG:Ljava/lang/String;

    new-instance v2, Ljava/lang/StringBuilder;

    const-string v3, "Failed to download "

    invoke-direct {v2, v3}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    invoke-virtual {v2, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    const-string v3, ", falling back to default image"

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v2

    invoke-static {v1, v2}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;)I

    .line 118
    invoke-direct {p0}, Lcom/bitauto/autoeasy/widget/RemoteImageView;->loadDefaultImage()V

    goto :goto_0

    .line 122
    :cond_1
    iput-object p1, p0, Lcom/bitauto/autoeasy/widget/RemoteImageView;->mUrl:Ljava/lang/String;

    .line 123
    iput v2, p0, Lcom/bitauto/autoeasy/widget/RemoteImageView;->mFailure:I

    .line 126
    :cond_2
    invoke-static {}, Lcom/bitauto/autoeasy/autoEasyApplication;->getInstance()Lcom/bitauto/autoeasy/autoEasyApplication;

    move-result-object v1

    invoke-virtual {v1}, Lcom/bitauto/autoeasy/autoEasyApplication;->getImageCache()Lcom/bitauto/autoeasy/tool/ImageCache;

    move-result-object v0

    .line 127
    .local v0, imageCache:Lcom/bitauto/autoeasy/tool/ImageCache;
    invoke-virtual {v0, p1}, Lcom/bitauto/autoeasy/tool/ImageCache;->isCached(Ljava/lang/String;)Z

    move-result v1

    if-eqz v1, :cond_3

    .line 128
    invoke-virtual {v0, p1}, Lcom/bitauto/autoeasy/tool/ImageCache;->get(Ljava/lang/Object;)Ljava/lang/Object;

    move-result-object v1

    check-cast v1, Landroid/graphics/Bitmap;

    invoke-virtual {p0, v1}, Lcom/bitauto/autoeasy/widget/RemoteImageView;->setImageBitmap(Landroid/graphics/Bitmap;)V

    goto :goto_0

    .line 132
    :cond_3
    :try_start_0
    new-instance v1, Lcom/bitauto/autoeasy/widget/RemoteImageView$DownloadTask;

    invoke-direct {v1, p0}, Lcom/bitauto/autoeasy/widget/RemoteImageView$DownloadTask;-><init>(Lcom/bitauto/autoeasy/widget/RemoteImageView;)V

    const/4 v2, 0x1

    new-array v2, v2, [Ljava/lang/String;

    const/4 v3, 0x0

    aput-object p1, v2, v3

    invoke-virtual {v1, v2}, Lcom/bitauto/autoeasy/widget/RemoteImageView$DownloadTask;->execute([Ljava/lang/Object;)Landroid/os/AsyncTask;
    :try_end_0
    .catch Ljava/util/concurrent/RejectedExecutionException; {:try_start_0 .. :try_end_0} :catch_0

    goto :goto_0

    .line 133
    :catch_0
    move-exception v1

    goto :goto_0
.end method

.method public setImageUrl(Ljava/lang/String;ILandroid/widget/GridView;)V
    .locals 0
    .parameter "url"
    .parameter "position"
    .parameter "gridView"

    .prologue
    .line 236
    iput p2, p0, Lcom/bitauto/autoeasy/widget/RemoteImageView;->mPosition:I

    .line 237
    iput-object p3, p0, Lcom/bitauto/autoeasy/widget/RemoteImageView;->mGridView:Landroid/widget/GridView;

    .line 238
    invoke-virtual {p0, p1}, Lcom/bitauto/autoeasy/widget/RemoteImageView;->setImageUrl(Ljava/lang/String;)V

    .line 239
    return-void
.end method

.method public setImageUrl(Ljava/lang/String;ILandroid/widget/ListView;)V
    .locals 0
    .parameter "url"
    .parameter "position"
    .parameter "listView"

    .prologue
    .line 230
    iput p2, p0, Lcom/bitauto/autoeasy/widget/RemoteImageView;->mPosition:I

    .line 231
    iput-object p3, p0, Lcom/bitauto/autoeasy/widget/RemoteImageView;->mListView:Landroid/widget/ListView;

    .line 232
    invoke-virtual {p0, p1}, Lcom/bitauto/autoeasy/widget/RemoteImageView;->setImageUrl(Ljava/lang/String;)V

    .line 233
    return-void
.end method

.method public setImageUrl2Drawable(Ljava/lang/String;)V
    .locals 5
    .parameter "url"

    .prologue
    const/4 v3, 0x0

    .line 141
    iget-object v2, p0, Lcom/bitauto/autoeasy/widget/RemoteImageView;->mListView:Landroid/widget/ListView;

    if-nez v2, :cond_0

    iget-object v2, p0, Lcom/bitauto/autoeasy/widget/RemoteImageView;->mCurrentlyGrabbedUrl:Ljava/lang/String;

    if-eqz v2, :cond_0

    iget-object v2, p0, Lcom/bitauto/autoeasy/widget/RemoteImageView;->mCurrentlyGrabbedUrl:Ljava/lang/String;

    invoke-virtual {v2, p1}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v2

    if-eqz v2, :cond_0

    .line 171
    :goto_0
    return-void

    .line 146
    :cond_0
    iget-object v2, p0, Lcom/bitauto/autoeasy/widget/RemoteImageView;->mUrl:Ljava/lang/String;

    if-eqz v2, :cond_1

    iget-object v2, p0, Lcom/bitauto/autoeasy/widget/RemoteImageView;->mUrl:Ljava/lang/String;

    invoke-virtual {v2, p1}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v2

    if-eqz v2, :cond_1

    .line 147
    iget v2, p0, Lcom/bitauto/autoeasy/widget/RemoteImageView;->mFailure:I

    add-int/lit8 v2, v2, 0x1

    iput v2, p0, Lcom/bitauto/autoeasy/widget/RemoteImageView;->mFailure:I

    .line 148
    iget v2, p0, Lcom/bitauto/autoeasy/widget/RemoteImageView;->mFailure:I

    sget v3, Lcom/bitauto/autoeasy/widget/RemoteImageView;->MAX_FAILURES:I

    if-le v2, v3, :cond_2

    .line 149
    sget-object v2, Lcom/bitauto/autoeasy/widget/RemoteImageView;->TAG:Ljava/lang/String;

    new-instance v3, Ljava/lang/StringBuilder;

    const-string v4, "Failed to download "

    invoke-direct {v3, v4}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    invoke-virtual {v3, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v3

    const-string v4, ", falling back to default image"

    invoke-virtual {v3, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v3

    invoke-virtual {v3}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v3

    invoke-static {v2, v3}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;)I

    .line 150
    invoke-direct {p0}, Lcom/bitauto/autoeasy/widget/RemoteImageView;->loadDefaultImage()V

    goto :goto_0

    .line 154
    :cond_1
    iput-object p1, p0, Lcom/bitauto/autoeasy/widget/RemoteImageView;->mUrl:Ljava/lang/String;

    .line 155
    iput v3, p0, Lcom/bitauto/autoeasy/widget/RemoteImageView;->mFailure:I

    .line 158
    :cond_2
    invoke-static {}, Lcom/bitauto/autoeasy/autoEasyApplication;->getInstance()Lcom/bitauto/autoeasy/autoEasyApplication;

    move-result-object v2

    invoke-virtual {v2}, Lcom/bitauto/autoeasy/autoEasyApplication;->getImageCache()Lcom/bitauto/autoeasy/tool/ImageCache;

    move-result-object v1

    .line 159
    .local v1, imageCache:Lcom/bitauto/autoeasy/tool/ImageCache;
    invoke-virtual {v1, p1}, Lcom/bitauto/autoeasy/tool/ImageCache;->isCached(Ljava/lang/String;)Z

    move-result v2

    if-eqz v2, :cond_3

    .line 161
    new-instance v0, Landroid/graphics/drawable/BitmapDrawable;

    invoke-virtual {v1, p1}, Lcom/bitauto/autoeasy/tool/ImageCache;->get(Ljava/lang/Object;)Ljava/lang/Object;

    move-result-object v2

    check-cast v2, Landroid/graphics/Bitmap;

    invoke-direct {v0, v2}, Landroid/graphics/drawable/BitmapDrawable;-><init>(Landroid/graphics/Bitmap;)V

    .line 162
    .local v0, drawable:Landroid/graphics/drawable/Drawable;
    invoke-virtual {p0, v0}, Lcom/bitauto/autoeasy/widget/RemoteImageView;->setBackgroundDrawable(Landroid/graphics/drawable/Drawable;)V

    goto :goto_0

    .line 166
    .end local v0           #drawable:Landroid/graphics/drawable/Drawable;
    :cond_3
    :try_start_0
    new-instance v2, Lcom/bitauto/autoeasy/widget/RemoteImageView$DownloadTask;

    invoke-direct {v2, p0}, Lcom/bitauto/autoeasy/widget/RemoteImageView$DownloadTask;-><init>(Lcom/bitauto/autoeasy/widget/RemoteImageView;)V

    const/4 v3, 0x1

    new-array v3, v3, [Ljava/lang/String;

    const/4 v4, 0x0

    aput-object p1, v3, v4

    invoke-virtual {v2, v3}, Lcom/bitauto/autoeasy/widget/RemoteImageView$DownloadTask;->execute([Ljava/lang/Object;)Landroid/os/AsyncTask;
    :try_end_0
    .catch Ljava/util/concurrent/RejectedExecutionException; {:try_start_0 .. :try_end_0} :catch_0

    goto :goto_0

    .line 167
    :catch_0
    move-exception v2

    goto :goto_0
.end method

.method public setImageUrlbyGrid(Ljava/lang/String;)V
    .locals 4
    .parameter "url"

    .prologue
    const/4 v2, 0x0

    .line 175
    iget-object v1, p0, Lcom/bitauto/autoeasy/widget/RemoteImageView;->mGridView:Landroid/widget/GridView;

    if-nez v1, :cond_0

    iget-object v1, p0, Lcom/bitauto/autoeasy/widget/RemoteImageView;->mCurrentlyGrabbedUrl:Ljava/lang/String;

    if-eqz v1, :cond_0

    iget-object v1, p0, Lcom/bitauto/autoeasy/widget/RemoteImageView;->mCurrentlyGrabbedUrl:Ljava/lang/String;

    invoke-virtual {v1, p1}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v1

    if-eqz v1, :cond_0

    .line 203
    :goto_0
    return-void

    .line 180
    :cond_0
    iget-object v1, p0, Lcom/bitauto/autoeasy/widget/RemoteImageView;->mUrl:Ljava/lang/String;

    if-eqz v1, :cond_1

    iget-object v1, p0, Lcom/bitauto/autoeasy/widget/RemoteImageView;->mUrl:Ljava/lang/String;

    invoke-virtual {v1, p1}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v1

    if-eqz v1, :cond_1

    .line 181
    iget v1, p0, Lcom/bitauto/autoeasy/widget/RemoteImageView;->mFailure:I

    add-int/lit8 v1, v1, 0x1

    iput v1, p0, Lcom/bitauto/autoeasy/widget/RemoteImageView;->mFailure:I

    .line 182
    iget v1, p0, Lcom/bitauto/autoeasy/widget/RemoteImageView;->mFailure:I

    sget v2, Lcom/bitauto/autoeasy/widget/RemoteImageView;->MAX_FAILURES:I

    if-le v1, v2, :cond_2

    .line 183
    sget-object v1, Lcom/bitauto/autoeasy/widget/RemoteImageView;->TAG:Ljava/lang/String;

    new-instance v2, Ljava/lang/StringBuilder;

    const-string v3, "Failed to download "

    invoke-direct {v2, v3}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    invoke-virtual {v2, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    const-string v3, ", falling back to default image"

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v2

    invoke-static {v1, v2}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;)I

    .line 184
    invoke-direct {p0}, Lcom/bitauto/autoeasy/widget/RemoteImageView;->loadDefaultImage()V

    goto :goto_0

    .line 188
    :cond_1
    iput-object p1, p0, Lcom/bitauto/autoeasy/widget/RemoteImageView;->mUrl:Ljava/lang/String;

    .line 189
    iput v2, p0, Lcom/bitauto/autoeasy/widget/RemoteImageView;->mFailure:I

    .line 192
    :cond_2
    invoke-static {}, Lcom/bitauto/autoeasy/autoEasyApplication;->getInstance()Lcom/bitauto/autoeasy/autoEasyApplication;

    move-result-object v1

    invoke-virtual {v1}, Lcom/bitauto/autoeasy/autoEasyApplication;->getImageCache()Lcom/bitauto/autoeasy/tool/ImageCache;

    move-result-object v0

    .line 193
    .local v0, imageCache:Lcom/bitauto/autoeasy/tool/ImageCache;
    invoke-virtual {v0, p1}, Lcom/bitauto/autoeasy/tool/ImageCache;->isCached(Ljava/lang/String;)Z

    move-result v1

    if-eqz v1, :cond_3

    .line 194
    invoke-virtual {v0, p1}, Lcom/bitauto/autoeasy/tool/ImageCache;->get(Ljava/lang/Object;)Ljava/lang/Object;

    move-result-object v1

    check-cast v1, Landroid/graphics/Bitmap;

    invoke-virtual {p0, v1}, Lcom/bitauto/autoeasy/widget/RemoteImageView;->setImageBitmap(Landroid/graphics/Bitmap;)V

    goto :goto_0

    .line 198
    :cond_3
    :try_start_0
    new-instance v1, Lcom/bitauto/autoeasy/widget/RemoteImageView$DownloadTask;

    invoke-direct {v1, p0}, Lcom/bitauto/autoeasy/widget/RemoteImageView$DownloadTask;-><init>(Lcom/bitauto/autoeasy/widget/RemoteImageView;)V

    const/4 v2, 0x1

    new-array v2, v2, [Ljava/lang/String;

    const/4 v3, 0x0

    aput-object p1, v2, v3

    invoke-virtual {v1, v2}, Lcom/bitauto/autoeasy/widget/RemoteImageView$DownloadTask;->execute([Ljava/lang/Object;)Landroid/os/AsyncTask;
    :try_end_0
    .catch Ljava/util/concurrent/RejectedExecutionException; {:try_start_0 .. :try_end_0} :catch_0

    goto :goto_0

    .line 199
    :catch_0
    move-exception v1

    goto :goto_0
.end method
